/** 该文件存放于用户相关的接口API */

import myaxios from '../MyAxios';
//引入路径前缀
import BASEURL from '../BaseURL';
const { BaseURL } = BASEURL;

const userApi = {
  /**
   * 查询所有用户
   * @param {Object} param {page:当前页,pagesize:数据量}
   * @returns Primose
   */
  queryAllUser(param) {
    let url = BaseURL + '/user';
    return myaxios.post(url, param);
  },

  /**
   * 添加用户
   * @param {Object} param {username:名字,password:密码,role:角色,addtime:添加时间}
   * @returns Primose
   */
  add(param) {
    let url = BaseURL + '/userAdd';
    return myaxios.post(url, param);
  },

  /**
   * 删除用户
   * @param {Object} param {id:1}
   * @returns Primose
   */
  delete(param) {
    let url = BaseURL + '/userDel';
    return myaxios.post(url, param);
  },

  /**
   * 修改用户信息
   * @param {Object} param {username:名字,password:密码,role:角色,id:1}
   * @returns Primose
   */
  update(param) {
    let url = BaseURL + '/userUpdate';
    return myaxios.post(url, param);
  },

  /**
   * 模糊查询用户
   * @param {Object} param {name:名字}
   * @returns Primose
   */
  queryLike(param) {
    let url = BaseURL + '/userLike/name';
    return myaxios.post(url, param);
  },
};

export default userApi;
